from models import *

   
   
def get_default_user():
    query = User.objects.filter(email=DEFAULT_USER_EMAIL)
    return query[0]

def get_problem_by_id(id):
    return Problem.objects.get(id=id)

def get_initial_problem(user):
    query = Problem.objects.filter(person=user).filter(is_initial_problem=True)
    if query.count() > 0:
        return query[0]
    else:
        return None
    
def get_problem_causes(user, p):
    return CausalRelation.objects.filter(person=user).filter(effect = p)